#include <iostream>
#include <vector>

using namespace std;

struct ListNode {
  int val;
  ListNode *next;
  ListNode() : val(0), next(nullptr) {}
  ListNode(int x) : val(x), next(nullptr) {}
  ListNode(int x, ListNode *next) : val(x), next(next) {}
};

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
  ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) {
    // 哨兵节点
    ListNode *preHead = new ListNode();
    ListNode *l3 = preHead;

    while (l1 != nullptr && l2 != nullptr) {
      if (l1->val < l2->val) {
        l3->next = l1;
        l1 = l1->next;
      } else {
        l3->next = l2;
        l2 = l2->next;
      }

      l3 = l3->next;
    }

    l3->next = l1 == nullptr ? l2 : l1;

    return preHead->next;
  }
};

int main() {
  ListNode *l1 = nullptr, *l2 = nullptr;

  ListNode *head;
  int number = 0;

  while (cin >> number) {
    ListNode *l = new ListNode(number);
    
    if (l1 == nullptr) {
      l1 = l;
      head = l1;
    } else {
      l1->next = l;
      l1 = l1->next;
    }

    if (cin.get() == '\n') {
      break;
    }
  }

  l1 = head;

  while (cin >> number) {
    ListNode *l = new ListNode(number);
    
    if (l2 == nullptr) {
      l2 = l;
      head = l2;
    } else {
      l2->next = l;
      l2 = l2->next;
    }

    if (cin.get() == '\n') {
      break;
    }
  }

  l2 = head;

  ListNode *l3 = Solution().mergeTwoLists(l1, l2);

  cout << '[';

  while (l3 != nullptr) {
    if (l3->next != nullptr) {
      cout << l3->val << ", ";
    } else {
      cout << l3->val;
    }
    l3 = l3->next;
  }

  cout << ']' << endl;

  return 0;
}